package com.kgcx.coupon.enums;

import com.kgcx.common.log.Log;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 广告位枚举
 * @author panjin.
 * @date 2017/12/18.
 */
@AllArgsConstructor
@Getter
@Slf4j
public enum AdPlaceEnum {

    CUSTOMER_APP_START(1, "用户端启动页"),
    CUSTOMER_APP_HOME_CAROUSEL(2, "用户端首页轮播"),
    DRIVER_APP_START(3, "司机端启动页");

    /**
     *  编码
     */
    private int code;

    /**
     * 字段含义
     */
    private String message;

    /**
     * 获取枚举类型
     * @param code 枚举编码
     * @return
     */
    public static AdPlaceEnum getEnum(int code) {
        for (AdPlaceEnum item : AdPlaceEnum.values()) {
            if (code == item.getCode()) {
                return item;
            }
        }
        log.warn(Log.op("get advert enum").msg("code param is out of range").kv("code", code).toString());
        return null;
    }
}
